package com.study.spmongodb.book.wwj.char17;

/**
 * @author MI
 * @version 1.0
 * @date 2020/11/29 10:01
 */
public interface ReadWriteLock {
    //创建reader锁
    Lock readLock();

    //创建write锁
    Lock writeLock();

    //获取当钱有多少线程正在执行写操作
    int getWritingWriters();

    //获取当前有多少线程正在等待获取写入锁
    int getWaitingWrtiers();

    //获取当前有多少线程正在等待获取reader锁
    int getReadingReaders();

    static ReadWriteLock readWriteLock() {
        return new ReadWriteLockImpl();
    }

    static ReadWriteLock readWriteLock(boolean preferWriter) {
        return new ReadWriteLockImpl(preferWriter);
    }
}
